<?php
session_start();
if(!$_SESSION['id'])
	header('location:../index.php');

function __autoload($class){
	include '../class/'.strtolower($class).'.class.php';
}

if($_POST['sub']){
	$_POST['sub']='';
	$art=new Article('');
	$entity=new Entity;
	$t_len=strlen($_POST['title']);
	$c_len=strlen($_POST['content']);

	if($t_len<12||$c_len<30){
		die(false);
	}else{
		$new=$entity->multiWrite(array($_POST['title'],$_POST['content'],$_POST['cat']));
		$art->writeBlog($new[0],$new[1],$new[2],$_SESSION['id']);
		$caution='<b>文章创建成功<br>请耐心等待管理员审核</b>';
	}
?>
		<div style="width:200px;height:100px;position:absolute;left:50%;top:50%;margin-left:-100px;margin-top:-50px;">
		<?php echo $caution ?>
		</div>
<?php }else{ ?>

		<div class="row-fluid">
			<div id="maincontent" class="span9">
				<div class="articles" id="display_articles">
						标题：<input id='write_title' type="text" placeholder="4到25字符之间"><br>
						类型：<select id="write_cat">
						<option >--请选择--</option>
						<option value="1">PHP</option>
						<option value="2">JS</option>
						<option value="3">Mysql</option>
						</select><br>
						类容：<textarea id="write_content" style="resize:none" rows="20" cols="40" placeholder="内容需要大于10个中文字符"></textarea><br>
						<button id="submit_article" style="position:fixed;bottom:10px;right:250px" class="btn">提交</button>
				</div>
			</div>	
		</div>
		</div>
<?php } ?>

